package com.yxkj.railservicer.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.yxkj.railservicer.R;
import com.yxkj.railservicer.bean.CancelBean;
import com.yxkj.railservicer.util.ContentUtil;

import java.util.List;

/**
 * Created by sunyu on 2017/4/4.
 */

public class CancelAdapter extends RecyclerView.Adapter<CancelAdapter.MyViewHolder> {

    private List<CancelBean> list;
    private Context context;

    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv_cancel_firstTime;
        TextView tv_cancel_order;
        TextView tv_cancel_time;
        ImageView iv_cancel_icon;
        TextView tv_cancel_name;
        TextView tv_cancel_address_get;
        TextView tv_cancel_address_post;
        TextView tv_cancel_reason;
        public MyViewHolder(View itemView) {
            super(itemView);

            tv_cancel_firstTime = (TextView) itemView.findViewById(R.id.tv_cancel_firstTime);
            tv_cancel_order = (TextView) itemView.findViewById(R.id.tv_cancel_order);
            tv_cancel_time = (TextView) itemView.findViewById(R.id.tv_cancel_time);
            iv_cancel_icon = (ImageView) itemView.findViewById(R.id.iv_cancel_icon);
            tv_cancel_name = (TextView) itemView.findViewById(R.id.tv_cancel_name);
            tv_cancel_address_get = (TextView) itemView.findViewById(R.id.tv_cancel_address_get);
            tv_cancel_address_post = (TextView) itemView.findViewById(R.id.tv_cancel_address_post);
            tv_cancel_reason = (TextView) itemView.findViewById(R.id.tv_cancel_reason);

        }
    }

    public CancelAdapter(List<CancelBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_cancel,parent,false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        CancelBean bean = list.get(position);
        holder.tv_cancel_firstTime.setText(bean.getFirst_time());
        holder.tv_cancel_order.setText(bean.getOrder_num());
        holder.tv_cancel_time.setText(bean.getLater_time());
        Picasso.with(context).load(bean.getIcon()).into(holder.iv_cancel_icon);
//        holder.iv_cancel_icon.setImageResource(R.drawable.business_logo);
        holder.tv_cancel_name.setText(bean.getName());
        holder.tv_cancel_address_get.setText(bean.getAddress_get());
        holder.tv_cancel_address_post.setText(bean.getAddress_post());
        holder.tv_cancel_reason.setText(bean.getCancel_reason());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
